home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 8 / FM Towns Free Software Collection 8.iso / t_os / artemis / artsrc2 / decimal.h next >
C/C++ Source or Header  |  1994-06-01  |  1KB  |  39 lines

  1. /*
  2. *    10bit固定小数演算        v. 1.0
  3. *    math.h を仮定する。
  4. */
  5.  
  6. /*
  7. *    x, y は固定少数に限定するよう, 注意して使う。
  8. *    足し算, 引き算はそのまま。 dummy で作ってもいいかもしれない。
  9. */ 
  10. #define multi( x, y )  ( (x) * (y) >> DECIMAL )
  11. #define div( x, y )    ( (x) / (y) << DECIMAL )
  12.  
  13. /*
  14. *    int multi( int x, int y ) { return x*y >> DECIMAL ;}    
  15. *    int div (int x,int y)     { return x/y << DECIMAL ;}
  16. */
  17.  
  18. extern int powd( int, int )            ;
  19.  
  20. /*
  21. *    小さい変数のための三角関数( 小さくマクローリン展開しただけ。 べきの展開の大きさは個別に tune せよ。)
  22. *    返り値も固定少数表現の整数である。 (COS for Small Decimal)
  23. */
  24. #define cossd( x )  ( DUNIT - powd( (x), 2 )/2 + powd( (x), 4 )/24 - powd( (x), 6 )/720 )
  25. #define sinsd( x )  ( (x) - powd( (x), 3 )/6 + powd( (x), 5 )/120 - powd( (x), 7)/5040 )
  26.  
  27. /*
  28. *    三角数列。 そのまま cos, sin の関数とみなす。
  29. */
  30. extern int cos512[1024];
  31. extern int sin512[1024];
  32. extern int acos512[2048+1];
  33. extern int asin512[2048+1];
  34. #define  cos512( x )    (cos512[x])
  35. #define  sin512( x )    (sin512[x])
  36. #define acos512( x )    (acos512[(x)+DUNIT])
  37. #define asin512( x )    (asin512[(x)+DUNIT])
  38. /* -DUNIT は負に対応するため, 数列は原点をずらして持っている。 */
  39.